package com.gdufs.secondhandwebsite.dao;

import com.gdufs.secondhandwebsite.entity.Comment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;


@SpringBootTest
@RunWith(SpringRunner.class)
public class testCommentMapper {
//    int CreateComment(Comment comment);
//    int DeleteCommentByPrimaryKey(Long commentId);
//    Comment SelectCommentByPrimaryKey(Long commentId);
//    int UpdateCommentSelective(Comment comment);
//    List<Comment> getAllComment();
//    List<Comment> SelectCommentByPostId(Long postId);
    @Autowired
    CommentMapper commentMapper;

    @Test
    public void testCreatComment(){
        Comment comment =new Comment();
        comment.setContent("回答帖子1的内容");
        comment.setPostId(1L);
        commentMapper.CreateComment(comment);
        Comment comment1 =new Comment();
        comment1.setContent("回答帖子2的内容");
        comment1.setPostId(2L);
        commentMapper.CreateComment(comment1);
        Comment comment2 =new Comment();
        comment2.setContent("回答帖子1的内容222");
        comment2.setPostId(1L);
        commentMapper.CreateComment(comment2);
    }
    @Test
    public void testSelectCommentByPostId(){
        List<Comment> list = commentMapper.SelectCommentByPostId(1L);
        for(Comment a:list){
            System.out.println(a);
        }
    }
    @Test
    public void testUpdateCommentSelective(){
        Comment c= commentMapper.SelectCommentByPrimaryKey(1l);
        c.setContent("改变一下"+c.getContent());
        commentMapper.UpdateCommentSelective(c);
    }

}
